package de.fhhof.robot.control.common;

import java.text.StringCharacterIterator;

import de.fhhof.robot.control.Color;

public class MessageUtility {

	public static int getRequiredColor(Color color,String payload){
		
		StringCharacterIterator iter = new StringCharacterIterator(payload);
		int counter = 0;
		for(char ch = iter.first();ch != iter.DONE; ch = iter.next()){
			if(ch == color.getCode()){
				counter ++;
			}
		}
		return counter;
	}
	public static void main(String args[]){
		int value = getRequiredColor(Color.RED, "rrjkjkjkrrrrrjjkjkjk");
		System.out.println(value);
	}
}
